-
-
Notifications
You must be signed in to change notification settings - Fork 227
fix: #457 Parameters from PathItem
can now be overriden in Operation
#458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: #457 Parameters from PathItem
can now be overriden in Operation
#458
Conversation
I shouldn’t have changed that behavior. I brought it back and fixed it for this PR. |
Replace dict.items() with dict.values() Co-authored-by: Dylan Anthony <[email protected]>
Replace dict.items() with dict.values() Co-authored-by: Dylan Anthony <[email protected]>
…ests\openapi.json`
@dbanty Thank you for the review! Added your suggestions and a test for the case you described. Also added forgotten |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for keeping up with this! I have one fix to an error message and a couple suggested refactors for easier readability (subjectively).
Co-authored-by: Dylan Anthony <[email protected]>
Co-authored-by: Dylan Anthony <[email protected]>
Co-authored-by: Dylan Anthony <[email protected]>
@dbanty Dylan, thanks for these improvements! I agree, and also added the missing test 👀 |
Codecov Report
@@ Coverage Diff @@
## main #458 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 47 47
Lines 1589 1592 +3
=========================================
+ Hits 1589 1592 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more tweak, sorry I didn't clarify in the last round.
Everything else looks good so I'm gonna try and tweak this myself real quick so you don't have to jump in here again. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for all your work on this!
This PR aims to fix the code generation with
PathItems
parameters overridingin
Operation
. Please, read more in #457 .Seems like overriding is job for
set
and__hash__
overriding. ButProperty
class isdefined with
@attr.s(auto_attribs=True, frozen=True)
. And how to achieve__hash__
overriding with +
frozen=True
is not obvious. It is the reason for usingdict
.Parameter location
list
-s replaced withdict
-s because it allows tobuild
Endpoint.from_data()
withOperation
parameters then addPathItem
parameters in
EndpointCollection.from_data()
bydict.setdefault()
to avoidOperation
parameters overriding with
PathItem
parameters.Removes from
Endpoint._add_parameters
Because parameter with location other than listed in
ParameterLocation(str, Enum)
willnot be validated by
pydantic
. So why do we need to check that case here twice?Add more obvious warning in duplicated parameters case.
Always use
{param.name}_{param.param_in}
python identifier for parameters because it leadsto more obvious usage and simplifies the code.
Please, pay attention to
test__add_parameters_happy
in
tests\test_parser\test_openapi.py
. I'm not sure if I have done it best way there.Custom templates in end-to-end tests did not pass. I believe I haven't touched them, but it
fails. I made it passing by making imports relative. I ran it on Windows, so maybe it fixes #447 ?